﻿using System;

namespace SmallDataBase.Attribute
{
    /// <summary>
    /// 列名属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
    public sealed class ColumnAttribute : System.Attribute
    {
        private readonly string _name;

        /// <summary>
        /// 列属性构造函数
        /// </summary>
        /// <param name="columnName">实体对应的数据库列名</param>
        /// <param name="isPK">是否主键</param>
        /// <param name="isAutoIncre">是否自增</param>
        public ColumnAttribute(string columnName, bool isPK, bool isAutoIncre)
        {
            _name = columnName;
            IsPrimaryKey = isPK;
            IsAutoIncrement = isAutoIncre;
        }

        /// <summary>
        /// 数据库列名
        /// </summary>
        public string ColumnName
        {
            get { return _name; }
        }

        /// <summary>
        /// 是否主键
        /// </summary>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// 是否自增
        /// </summary>
        public bool IsAutoIncrement { get; set; }
    }
}